package Draw;

import javax.swing.*;
import java.awt.*;

/*
 *@Student 张策
 */
public class DrawCircle extends JFrame{//画框
    private MyPanel mp=null;//画板
    public static void main(String[] args) {
        new DrawCircle();
    }

    public DrawCircle(){
        //初始化画板
        mp=new MyPanel();
        //将画板加到画框
        this.add(mp);
        //设置窗口大小
        this.setSize(900,900);
        //可以显示
        this.setVisible(true);
        //点小×后退出程序
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
class MyPanel extends JPanel {
    @Override
    public void paint(Graphics g) {
        super.paint(g);//调用父类的方法进行初始化
        g.setColor(Color.BLUE);//画笔颜色
        g.drawOval(0,0,600,600);//画圆
        g.fillOval(0,0,200,200);//填充
        Image image = Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/QQ图片20240104075246.jpg"));
        g.drawImage(image,10,10,180,440,this);
        g.setFont(new Font("宋体",Font.BOLD,50));
        g.drawString("牛",100,500);

    }

}
